GOOGLE_WIPG_SITE=repo://vendor/google/wipg
GOOGLE_WIPG_INSTALL_STAGING=YES
GOOGLE_WIPG_INSTALL_TARGET=YES

GOOGLE_WIPG_DEPENDENCIES=

HOST_GOOGLE_WIPG_DEPENDENCIES=\
	$(GOOGLE_WIPG_DEPENDENCIES)

GOOGLE_WIPG_TARGET_CFLAGS=
GOOGLE_WIPG_HOST_CFLAGS=-isystem $(HOST_DIR)/usr/include

ifeq ($(BR2_PACKAGE_GOOGLE_WIPG_MACSEC),y)
BUILD_MACSEC=y
GOOGLE_WIPG_DEPENDENCIES += mv_physdk
endif

ifeq ($(BR2_PACKAGE_GOOGLE_WIPG_PHYTOOL),y)
BUILD_PHYTOOL=y
GOOGLE_WIPG_DEPENDENCIES += mv_physdk
endif

WIPG_MAKE_ENV = \
	INSTALL=$(INSTALL) \
	HOSTDIR=$(HOST_DIR) \
	TARGET_CROSS=$(TARGET_CROSS) \
	HOST_CC="$(HOSTCC)" \
	HOST_CXX="$(HOSTCXX)" \

TARGET_WIPG_MAKE = \
	$(WIPG_MAKE_ENV) \
		DESTDIR=$(TARGET_DIR) \
		EXTRACFLAGS="$(TARGET_CFLAGS) $(GOOGLE_WIPG_TARGET_CFLAGS)" \
		EXTRACXXFLAGS="$(TARGET_CXXFLAGS) $(GOOGLE_WIPG_TARGET_CFLAGS)" \
		BUILD_MACSEC=$(BUILD_MACSEC) \
		BUILD_PHYTOOL=$(BUILD_PHYTOOL) \
		$(MAKE)

HOST_WIPG_MAKE = \
	$(WIPG_MAKE_ENV) \
		DESTDIR=$(HOST_DIR) \
		EXTRACFLAGS="$(HOST_CFLAGS) -L$(HOST_DIR)/usr/lib $(GOOGLE_WIPG_HOST_CFLAGS)" \
		EXTRACXXFLAGS="$(HOST_CXXFLAGS) -L$(HOST_DIR)/usr/lib $(GOOGLE_WIPG_HOST_CFLAGS)" \
		EXTRALDFLAGS="$(HOST_LDFLAGS) -L$(HOST_DIR)/usr/lib" \
		$(MAKE)

define GOOGLE_WIPG_BUILD_CMDS
	$(TARGET_WIPG_MAKE) -C $(@D) build
endef

define HOST_GOOGLE_WIPG_BUILD_CMDS
	$(HOST_WIPG_MAKE) -C $(@D) build
endef

define HOST_GOOGLE_WIPG_TEST_CMDS
	$(HOST_WIPG_MAKE) -C $(@D) test
endef

define GOOGLE_WIPG_INSTALL_STAGING_CMDS
	$(TARGET_WIPG_MAKE) -C $(@D) DESTDIR=$(STAGING_DIR) install-libs
endef

define HOST_GOOGLE_WIPG_INSTALL_CMDS
	$(HOST_WIPG_MAKE) -C $(@D) install-libs
endef

define GOOGLE_WIPG_INSTALL_TARGET_CMDS
	$(TARGET_WIPG_MAKE) -C $(@D) install
endef

$(eval $(call GENTARGETS))
$(eval $(call GENTARGETS,host))
